<template>
  <div class="search">
    <input v-model="value" type="text" />
    <button :style="{ backgroundColor: $store.state.color }" @click="add">
      提交
    </button>
  </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
export default {
  setup(props, { emit }) {
    let value = ref("");
    let store = useStore();
    // 添加
    function add() {
      store.commit("pushObj", value.value);
    }

    return { value, add };
  },
  components: {},
};
</script>

<style lang="scss" scoped>
.search {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  display: flex;
  justify-content: space-around;
  input {
    width: 60%;
    height: 30px;
    border-radius: 4px;
  }
  button {
    width: 60px;
    height: 35px;
    background-color: pink;
    border-radius: 8px;
    border: 0;
    color: #fff;
  }
}
</style>
